package com.asman.vr.network

import com.asman.vr.constant.UrlConst.WORKER_HOST_URL
import com.asman.vr.network.ApiService.httpClient
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object ApiWorkerService {

    private val builder =
        Retrofit.Builder().baseUrl(WORKER_HOST_URL()).client(httpClient().build())
            .addCallAdapterFactory(CoroutineCallAdapterFactory())
            .addConverterFactory(GsonConverterFactory.create())

    private val retrofit = builder.build()

    fun <API> create(serviceClass: Class<API>): API = retrofit.create(serviceClass)

}